<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})">
<!--    &lt;!&ndash; 改版Bootstrap &ndash;&gt;-->
<!--    <link th:href="@{/css/sb-admin-2.css}" rel="stylesheet">-->
</head>
<body class="timo-layout-page">
    <div class="layui-card">
        <div class="layui-card-header timo-card-header">
            <span><i class="fa fa-bars"></i> 查看稿件管理</span>
            <i class="layui-icon layui-icon-refresh refresh-btn"></i>
        </div>
        <div class="layui-card-body">
            <div class="layui-row timo-card-screen">
                <div class="pull-left layui-form-pane timo-search-box">
                    <div class="layui-inline">
                        <label class="layui-form-label">状态</label>
                        <div class="layui-input-block timo-search-status">
                            <select class="timo-search-select" style="width: 125px;" name="status">
<!--                            <select class="timo-search-select" name="status" mo:dict="SEARCH_STATUS" mo-selected="${param.status}">-->
                                <option value="1">待审核</option>
                                <option value="6">审核通过</option>
                                <option value="7">审核未通过</option>
                                <option value="8">已支付</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline" style="margin-left: 55px;">
                        <label class="layui-form-label">文章标题</label>
                        <div class="layui-input-block">
                            <input type="text" name="title" th:value="${param.title}" placeholder="请输入文章标题" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">文章内容</label>
                        <div class="layui-input-block">
                            <input type="text" name="content" th:value="${param.content}" placeholder="请输入文章内容" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">文章分类</label>
                        <div class="layui-input-block">
                            <input type="text" name="articleClass" th:value="${param.articleClass}" placeholder="请输入文章分类" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn timo-search-btn">
                            <i class="fa fa-search"></i>
                        </button>
                    </div>
                </div>
                <div class="pull-right screen-btn-group">
                    <button class="layui-btn open-popup" data-title="添加查看稿件" th:attr="data-url=@{/system/article/add}" data-size="auto">
                        <i class="fa fa-plus"></i> 添加</button>
                    <div class="btn-group">
                        <button class="layui-btn">操作<span class="caret"></span></button>
                        <dl class="layui-nav-child layui-anim layui-anim-upbit">
                            <dd><a class="ajax-status" th:href="@{/system/article/status/ok}">启用文章</a></dd>
                            <dd><a class="ajax-status" th:href="@{/system/article/status/freezed}">封禁文章</a></dd>
                            <dd><a class="ajax-status" th:href="@{/system/article/status/pass}">通过稿件</a></dd>
                            <dd><a class="ajax-status" th:href="@{/system/article/status/delete}">删除</a></dd>
                        </dl>
                    </div>
                </div>
            </div>
            <div class="timo-table-wrap">
                <table class="layui-table timo-table">
                    <thead>
                    <tr>
                        <th class="timo-table-checkbox">
                            <label class="timo-checkbox"><input type="checkbox">
                                <i class="layui-icon layui-icon-ok"></i></label>
                        </th>
                        <th>文章ID</th>
                        <th>文章标题</th>
                        <th>作者</th>
                        <th>文章内容</th>
                        <th>文章分类</th>
                        <th>创建时间</th>
                        <th>稿件状态</th>
                        <th>稿费金额</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr th:each="item:${list}">
                        <td><label class="timo-checkbox"><input type="checkbox" th:value="${item.id}">
                            <i class="layui-icon layui-icon-ok"></i></label></td>
                        <td th:text="${item.id}">文章ID</td>
                        <td>
                            <a th:href="'/system/article/read/'+${item.id}" th:text="${item.title}">文章标题</a>
                        </td>
                        <td th:text="${item.createBy.nickname}">作者</td>
                        <td class="articleContent" th:utext="${item.content}">文章内容</td>

                        <td th:switch="${item.articleClass}">
                            <span th:case="1">前后台技术</span>
                            <span th:case="2">计算机软件</span>
                            <span th:case="3">计算机硬件</span>
                            <span th:case="4">其他</span>
                            <span th:case="*">未分类</span>
                        </td>

                        <td th:text="${#dates.format(item.createDate, 'yyyy-MM-dd HH:mm:ss')}">创建时间</td>
                        <td th:text="${#dicts.dataStatus(item.status)}=='正常'?'待审核':${#dicts.dataStatus(item.status)}">稿件状态</td>
                        <td th:id="'paymentFor'+${item.id}" th:text="${item.payment}==null?'未填写':${item.payment.money}">支付金额</td>
                        <td>
                            <a class="open-popup" data-title="编辑查看稿件" th:attr="data-url=@{'/system/article/edit/'+${item.id}}" data-size="auto" href="#">编辑稿件</a>
                            <a class="open-popup" data-title="详细信息" th:attr="data-url=@{'/system/article/detail/'+${item.id}}" data-size="800,600" href="#">详细</a>
<!--                            <a class="ajax-get" data-msg="您是否确认删除" th:href="@{/system/article/status/delete(ids=${item.id})}">删除</a>-->
                            <a class="" target="_blank" th:href="'/system/article/read/'+${item.id}" data-size="800,600">阅读该文章</a>
                            <label class="input-group-sm">
                                <input style="width: 85px;height:25px;" class="layui-input" th:id="'paymentInputID'+${item.getId()}">
                            </label>
                            <a th:name="${item.id}" class="" onclick="setPayment(this.name)">设置稿费金额</a>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <div th:replace="/common/fragment :: page"></div>
        </div>
    </div>
    <script th:src="@{/vendor/jquery/jquery.min.js}"></script>
    <script th:src="@{/js/ContentFiltering.js}"></script>
<script th:replace="/common/template :: script"></script>
<script>
    function setPayment(ID) {
        //console.log(ID);
        let money = $("#paymentInputID"+ID).val();
        $.get("/system/payment/setPayment?money=" + money+"&article_id="+ID, function (data) {
            //console.log(data);
            console.log(data.msg);
            let msg = data.msg;
            if(msg==="设置成功"){
                $("#paymentFor"+ID).text(money);
                //window.location.reload();
            }
            //console.log("文章ID:"+ID+"的稿费设置成功，为："+money);
        });
    }
</script>
</body>
</html>